package com.xxx.generic;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/21 13:50
 * @Copyright 博为峰
 */
public class GenericDemo03 {
    public static void main(String[] args) {
        ArrayList<String> strings = new ArrayList<>();
        strings.add("a");
        strings.add("b");
        it(strings);


        ArrayList<Integer> integers = new ArrayList<>();
        integers.add(1);
        integers.add(2);
        it(integers);

    }

    //通配符
    public static void it(ArrayList<?> list) {
        Iterator<?> iterator = list.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

    }
}
